package cn.ch.train.business.controller.admin;

import cn.ch.train.common.context.LoginMemberContext;
import cn.ch.train.common.response.CommonResponse;
import cn.ch.train.common.response.PageResult;
import cn.ch.train.business.request.TrainStationQueryParam;
import cn.ch.train.business.request.TrainStationSaveParam;
import cn.ch.train.business.response.TrainStationQueryResult;
import cn.ch.train.business.service.TrainStationService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/train-station")
public class TrainStationAdminController {
    @Autowired
    private TrainStationService trainStationService;

    @PostMapping("/save")
    public CommonResponse save(@Valid @RequestBody TrainStationSaveParam param) {
        trainStationService.save(param);
        return new CommonResponse<>();
    }

    @GetMapping("/query-list")
    public CommonResponse<PageResult<TrainStationQueryResult>> queryList(@Valid TrainStationQueryParam param) {
        PageResult<TrainStationQueryResult> trainStationList = trainStationService.queryList(param);
        return new CommonResponse<>(trainStationList);
    }

    @DeleteMapping("/delete/{id}")
    public CommonResponse delete(@PathVariable Long id) {
        trainStationService.delete(id);
        return new CommonResponse<>();
    }

}
